/*
 * @Date: 2022-07-05 09:34:47
 * @LastEditTime: 2022-07-05 09:43:12
 */
// 数组求和
const sum = (array) => {
  let res = 0
  let len = array.length
  for (let i = 0; i < len; i++) {
    res += array[i]
  }
  return res
}

// star数组求平均值
export const getAverageStar = (array) => {
  return ((sum(array.map((val, index) => val * index))) / sum(array)).toFixed(1)
}
